package com.lv.service

import com.lv.common.network.KtRetrofit
import com.lv.common.utils.getBaseHost
import com.lv.service.model.IServiceResource
import com.lv.service.model.ServiceRepo
import com.lv.service.model.ServiceViewModel
import com.lv.service.net.ServiceService
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.core.parameter.parametersOf
import org.koin.dsl.bind
import org.koin.dsl.module

/**
 * 作者： ygx
 * 创建日期：2022/1/20 9:58 PM
 * 签名： 天行健，君子以自强不息；地势坤，君子以厚德载物。
 *      _              _           _     _   ____  _             _ _
 *     / \   _ __   __| |_ __ ___ (_) __| | / ___|| |_ _   _  __| (_) ___
 *    / _ \ | '_ \ / _` | '__/ _ \| |/ _` | \___ \| __| | | |/ _` | |/ _ \
 *   / ___ \| | | | (_| | | | (_) | | (_| |  ___) | |_| |_| | (_| | | (_) |
 *  /_/   \_\_| |_|\__,_|_|  \___/|_|\__,_| |____/ \__|\__,_|\__,_|_|\___/
 *
 * You never know what you can do until you try !
 * ----------------------------------------------------------------
 * Service模块相关的koin的module配置
 */

val moduleService = module {
    //service retrofit
    single<KtRetrofit> { (host: String) -> KtRetrofit.initConfig(host) }
    single {
        get<KtRetrofit> { parametersOf(getBaseHost()) }.getService(ServiceService::class.java)
    }
    //repo LoginResource

    single { ServiceRepo(get()) } bind IServiceResource::class

    //viewModel

    viewModel { ServiceViewModel(get()) }
}